home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / ScrollingPanel.as < prev    next >
Text File  |  2013-04-24  |  10KB  |  252 lines

  1. class ScrollingPanel extends State
  2. {
  3.    static var sSTATE_TITLE = "TitleCard";
  4.    static var sSTATE_TITLE_TO_HOWTOPLAY = "TitleToHowToPlay";
  5.    static var sSTATE_HOWTOPLAY = "HowToPlay";
  6.    static var sSTATE_HOWTOPLAY_TO_TITLE = "HowToPlayToTitle";
  7.    static var sSTATE_HIGHSCORES = "HighScores";
  8.    static var sSTATE_HIGHSCORES_TO_TITLE = "HighScoresToTitle";
  9.    static var sSTATE_TITLE_TO_HIGHSCORES = "TitleToHighScores";
  10.    function ScrollingPanel(_mcRef)
  11.    {
  12.       super(_mcRef);
  13.       this.setState(ScrollingPanel.sSTATE_TITLE);
  14.       this.nInstructionsPage = 1;
  15.       this.nKeyPosition = 1;
  16.    }
  17.    function setState(_sState)
  18.    {
  19.       this.sLastState = this.sState;
  20.       super.setState(_sState);
  21.       this.initState(_sState);
  22.    }
  23.    function TitleToHowToPlay()
  24.    {
  25.       if(this.stateFinished())
  26.       {
  27.          var _loc2_ = this.mcRef.mcState.mcPanel.mcPage.mcKeys._currentframe;
  28.          this.setState(ScrollingPanel.sSTATE_HOWTOPLAY);
  29.          this.mcRef.mcState.mcPanel.mcPage.mcKeys.gotoAndPlay(_loc2_);
  30.       }
  31.    }
  32.    function HowToPlayToTitle()
  33.    {
  34.       if(this.stateFinished())
  35.       {
  36.          this.nKeyPosition = this.mcRef.mcState.mcPanel.mcPage.mcKeys._currentframe;
  37.          this.setState(ScrollingPanel.sSTATE_TITLE);
  38.       }
  39.    }
  40.    function TitleToHighScores()
  41.    {
  42.       if(this.stateFinished())
  43.       {
  44.          this.changeStateKeepingInfo(ScrollingPanel.sSTATE_HIGHSCORES);
  45.       }
  46.    }
  47.    function HighScoresToTitle()
  48.    {
  49.       if(this.stateFinished())
  50.       {
  51.          this.setState(ScrollingPanel.sSTATE_TITLE);
  52.       }
  53.    }
  54.    function TitleCard()
  55.    {
  56.    }
  57.    function HighScores()
  58.    {
  59.    }
  60.    function Instructions()
  61.    {
  62.    }
  63.    function moveTitleToIns()
  64.    {
  65.       this.setState(ScrollingPanel.sSTATE_TITLE_TO_HOWTOPLAY);
  66.       this.mcRef.mcState.mcPanel.mcPage.mcKeys.gotoAndPlay(this.nKeyPosition);
  67.       this.initPage();
  68.    }
  69.    function moveTitleToHighScores()
  70.    {
  71.       Main.getRef().setMustSendScore(false);
  72.       this.setState(ScrollingPanel.sSTATE_TITLE_TO_HIGHSCORES);
  73.       Main.getRef().showHighScoreStuff(this.mcRef.mcState.mcPanel.mcSubmit);
  74.       this.checkToSubmitHighScore();
  75.       this.mcRef.mcState.mcPanel.mcSubmit._visible = false;
  76.       this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(2);
  77.    }
  78.    function desactivateButton(_mcButton)
  79.    {
  80.       delete _mcButton.button.onRollOver;
  81.       _mcButton.button.onRollOver = undefined;
  82.       delete _mcButton.button.onRelease;
  83.       _mcButton.button.onRelease = undefined;
  84.       _mcButton.gotoAndStop(2);
  85.    }
  86.    function activateButton(_mcButton, _onRelease)
  87.    {
  88.       _mcButton.gotoAndStop(1);
  89.       _mcButton.button.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  90.       _mcButton.button.onRelease = Delegate.create(this,_onRelease);
  91.    }
  92.    function nextPage()
  93.    {
  94.       Controller.getRef().playClickSound();
  95.       this.nInstructionsPage = this.nInstructionsPage + 1;
  96.       this.initPage();
  97.    }
  98.    function previousPage()
  99.    {
  100.       Controller.getRef().playClickSound();
  101.       this.nInstructionsPage = this.nInstructionsPage - 1;
  102.       this.initPage();
  103.    }
  104.    function initPage()
  105.    {
  106.       if(this.nInstructionsPage == 1)
  107.       {
  108.          this.desactivateButton(this.mcRef.mcState.mcPanel.mcBack);
  109.          this.activateButton(this.mcRef.mcState.mcPanel.mcNext,this.nextPage);
  110.       }
  111.       else if(this.nInstructionsPage == 2)
  112.       {
  113.          this.activateButton(this.mcRef.mcState.mcPanel.mcBack,this.previousPage);
  114.          this.activateButton(this.mcRef.mcState.mcPanel.mcNext,this.nextPage);
  115.       }
  116.       else if(this.nInstructionsPage == 3)
  117.       {
  118.          this.activateButton(this.mcRef.mcState.mcPanel.mcBack,this.previousPage);
  119.          this.desactivateButton(this.mcRef.mcState.mcPanel.mcNext);
  120.       }
  121.       this.mcRef.mcState.mcPanel.mcPage.gotoAndStop(this.nInstructionsPage);
  122.    }
  123.    function checkToSubmitHighScore()
  124.    {
  125.       if(_global.gProxyObj.getIsLoggedIn())
  126.       {
  127.          this.mcRef.mcState.mcPanel.mcSubmit._visible = true;
  128.       }
  129.       else
  130.       {
  131.          this.mcRef.mcState.mcPanel.mcSubmit._visible = false;
  132.       }
  133.       if(Main.getRef().MustSendScore)
  134.       {
  135.          this.clickSubmitButton();
  136.       }
  137.       else
  138.       {
  139.          _global.HS.getScores();
  140.       }
  141.    }
  142.    function initState(_sState)
  143.    {
  144.       switch(_sState)
  145.       {
  146.          case ScrollingPanel.sSTATE_TITLE:
  147.             _global.HS.initHiScores();
  148.             this.mcRef.mcState.mcPanel.btnPlay2.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  149.             this.mcRef.mcState.mcPanel.btnPlay2.onRelease = Delegate.create(Main.getRef(),Main.getRef().clickPlayButton);
  150.             this.mcRef.mcState.mcPanel.btnHighScores.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  151.             this.mcRef.mcState.mcPanel.btnHighScores.onRelease = Delegate.create(this,this.clickTitleToHSButton);
  152.             this.mcRef.mcState.mcPanel.btnHowToPlay.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  153.             this.mcRef.mcState.mcPanel.btnHowToPlay.onRelease = Delegate.create(this,this.clickTitleToInsButton);
  154.             this.mcRef.mcState.mcPanel.btnCheat.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  155.             this.mcRef.mcState.mcPanel.btnCheat.onRelease = Delegate.create(this,this.clickEnterCodeButton);
  156.             break;
  157.          case ScrollingPanel.sSTATE_HOWTOPLAY:
  158.             this.mcRef.mcState.mcPanel.btnPlay1.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  159.             this.mcRef.mcState.mcPanel.btnPlay1.onRelease = Delegate.create(Main.getRef(),Main.getRef().clickPlayButton);
  160.             this.initPage();
  161.             break;
  162.          case ScrollingPanel.sSTATE_HIGHSCORES:
  163.             if(this.sLastState == ScrollingPanel.sSTATE_TITLE_TO_HIGHSCORES)
  164.             {
  165.                this.mcRef.mcState.mcPanel.mcSubmit._visible = false;
  166.             }
  167.             else
  168.             {
  169.                Main.getRef().showHighScoreStuff(this.mcRef.mcState.mcPanel.mcSubmit);
  170.                this.checkToSubmitHighScore();
  171.             }
  172.             if(this.mcRef.mcState.mcPanel.mcSubmit._visible)
  173.             {
  174.                this.mcRef.mcState.mcPanel.mcSubmit.btnSubmit.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  175.                this.mcRef.mcState.mcPanel.mcSubmit.btnSubmit.onRelease = Delegate.create(this,this.clickSubmitButton);
  176.                this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(1);
  177.             }
  178.             else
  179.             {
  180.                this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(2);
  181.             }
  182.             this.mcRef.mcState.mcPanel.mcMain.btnHSToTitle.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  183.             this.mcRef.mcState.mcPanel.mcMain.btnHSToTitle.onRelease = Delegate.create(this,this.clickHSToTitleButton);
  184.       }
  185.    }
  186.    function clickTitleToInsButton()
  187.    {
  188.       Controller.getRef().playClickSound();
  189.       this.moveTitleToIns();
  190.    }
  191.    function clickTitleToHSButton()
  192.    {
  193.       Controller.getRef().playClickSound();
  194.       this.moveTitleToHighScores();
  195.    }
  196.    function clickHSToTitleButton()
  197.    {
  198.       Controller.getRef().playClickSound();
  199.       this.changeStateKeepingInfo(ScrollingPanel.sSTATE_HIGHSCORES_TO_TITLE);
  200.    }
  201.    function clickInsToTitleButton()
  202.    {
  203.       Controller.getRef().playClickSound();
  204.       var _loc2_ = this.mcRef.mcState.mcPanel.mcPage.mcKeys._currentframe;
  205.       this.setState(ScrollingPanel.sSTATE_HOWTOPLAY_TO_TITLE);
  206.       this.mcRef.mcState.mcPanel.mcPage.mcKeys.gotoAndPlay(_loc2_);
  207.       this.initPage();
  208.    }
  209.    function clickEnterCodeButton()
  210.    {
  211.       Controller.getRef().playClickSound();
  212.       Controller.getRef().getCheatPop().doShow();
  213.    }
  214.    function clickSubmitButton()
  215.    {
  216.       _global.HS.submitScore(CTRLGame.getRef().Score);
  217.       this.mcRef.mcState.mcPanel.mcSubmit._visible = false;
  218.       if(this.mcRef.mcState.mcPanel.mcSubmit._visible)
  219.       {
  220.          this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(1);
  221.       }
  222.       else
  223.       {
  224.          this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(2);
  225.       }
  226.    }
  227.    function changeStateKeepingInfo(_sNextState)
  228.    {
  229.       var _loc3_ = this.mcRef.mcState.mcPanel.mcSubmit._visible;
  230.       var _loc4_ = this.mcRef.mcState.mcPanel.txt_highScoreNumber.text;
  231.       var _loc5_ = this.mcRef.mcState.mcPanel.txt_highScoreName.text;
  232.       var _loc6_ = this.mcRef.mcState.mcPanel.txt_highScoreScore.text;
  233.       var _loc7_ = this.mcRef.mcState.mcPanel.txt_highScoreScore.scroll;
  234.       this.setState(_sNextState);
  235.       this.mcRef.mcState.mcPanel.mcSubmit._visible = _loc3_;
  236.       if(this.mcRef.mcState.mcPanel.mcSubmit._visible)
  237.       {
  238.          this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(1);
  239.       }
  240.       else
  241.       {
  242.          this.mcRef.mcState.mcPanel.mcMain.gotoAndStop(2);
  243.       }
  244.       this.mcRef.mcState.mcPanel.txt_highScoreNumber.text = _loc4_;
  245.       this.mcRef.mcState.mcPanel.txt_highScoreName.text = _loc5_;
  246.       this.mcRef.mcState.mcPanel.txt_highScoreScore.text = _loc6_;
  247.       this.mcRef.mcState.mcPanel.txt_highScoreNumber.scroll = _loc7_;
  248.       this.mcRef.mcState.mcPanel.txt_highScoreName.scroll = _loc7_;
  249.       this.mcRef.mcState.mcPanel.txt_highScoreScore.scroll = _loc7_;
  250.    }
  251. }
  252.